package com.toggery.POS.service;

import com.toggery.POS.dao.OrdersMapper;
import com.toggery.POS.entity.Orderdetail;
import com.toggery.POS.entity.Orders;
import com.toggery.POS.entity.OrderRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderService {
    @Autowired
    OrdersMapper mapper;

    public List<OrderRecord> findAll(){
        return  mapper.queryForList();
    }

    public boolean save(Orders order){
        if(mapper.selectByPrimaryKey(order.getId())==null){
            mapper.insert(order);
            return true;
        }else {
            return false;
        }
    }

    public boolean updateOrder(Orders order){
        if(mapper.updateByPrimaryKey(order)>0){
            return true;
        }else {
            return false;
        }
    }
    public boolean deleteByid(int id){
        if(mapper.deleteByPrimaryKey(id)>0){
            return true;
        }else {
            return false;
        }
    }
    public Orders findById(int id){
        return mapper.selectByPrimaryKey(id);
    }


//    public List<Order> findAllWithin() {
//        return mapper.findAll();
//    }
}
